{% with messages = get_flashed_messages(with_categories=true) -%}
    {% if messages -%}
        {% for category, message in messages -%}
            <div class="alert alert-{{ category }}">
                <a class="close" data-dismiss="alert" href="#" aria-hidden="true">&times;</a>
                {{ message }}
            </div>
        {%- endfor %}
    {%- endif %}
{%- endwith %}
